package com.fanjia.es_demo.controller;

import com.fanjia.es_demo.service.ContentService;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author fanjia
 * @className contentController
 * @description TODO
 * @date 2021/4/14 21:11
 */
@RestController
public class ContentController {

    @Autowired
    ContentService contentService;
    @GetMapping("/parse/{keywords}")
    public boolean parse(@PathVariable String keywords) throws IOException {
        return contentService.parseContent(keywords);
    }

    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String,Object>> search(@PathVariable String keyword,@PathVariable() int pageNo,@PathVariable int pageSize) throws IOException {
         return contentService.searchPageHighlightBuilder(keyword,pageNo,pageSize);

    }












}
